<?php

namespace App\Models;

use App\Models\Project\ProjectType;
use Daijulong\LaravelRoles\Traits\SingleRoleUserModel;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable, SoftDeletes, SingleRoleUserModel;

    /**
     * The attributes that are mass assignable.
     *
     * @var string[]
     */
    protected $fillable = [
        'name',
        'email',
        'mobile',
        'wxid',
        'password',
        'role_id',
        'enable',
        'view_permission',
        'avatar',
        'intro',
        'sex',
        'remember_token',
        'api_token',
        'confirmation_token',
        'mobile_confirmed',
        'email_confirmed',
        'enabled',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    protected function roleModel()
    {
        return UserRole::class;
    }


    public function projectType()
    {
        return $this->belongsToMany(ProjectType::class,'user_project_type','user_id','project_type_id');
    }



}
